<?
class appointment {
	var $res;
	var $customer;
	var $starttime;
	var $endtime;
	var $staff;
	var $service;
	var $staffid;
	var $status;
	var $statuscolor;
	var $currentrow;
	var $tooltiop;
	var $appt_id;
	
	function appointment($date) {
		$res = getAppointments($date);
		while($obj = mysql_fetch_object($res)) {
			$this->customer[] = $obj->firstname." ".$obj->lastname;
			$this->starttime[] = $obj->starttime;
			$this->endtime[] = $obj->endtime;
			$this->staff[] = $obj->first_name." ".$obj->last_name;
			$this->service[] = $obj->title;
			$this->staffid[] = $obj->staff_id;
			$this->statuscolor[] = $obj->color;
			$this->status[] = $obj->description;
			$this->appt_id[] = $obj->appt_id;
		}

	}

	function checkReserved($time,$staffid) {
		$time = $time + 1;

		for($i=0;$i<count($this->starttime);$i++) {
			if($time>$this->starttime[$i] && $time<$this->endtime[$i] && $this->staffid[$i]==$staffid) {
				$this->currentrow=$i;
				$this->createTooltip();
				return true;
			}
		}
		return false;
	}

	function createTooltip() {
		$this->tooltip = "Customer : ".$this->customer[$this->currentrow]."<br>
			Date : ".date('dS M,y H:i',$this->starttime[$this->currentrow])." - ".date('H:i',$this->endtime[$this->currentrow])."<br>
			With : ".$this->staff[$this->currentrow]."<br> 
			For : ".$this->service[$this->currentrow]."<br>
			Status : ".$this->status[$this->currentrow];
	}
 
}

?>